﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domains
{
    public class Ide : Domain
    {
        public string Value { get; set; }
        public Ide(string value)
        {
            if (value == null) throw new ArgumentNullException("argument is null");

            char[] Letters = value.ToCharArray();
            char firstLetter = Letters[0];
            char[] anotherLetters = new char[value.Length - 1];

            Array.Copy(Letters, 1, anotherLetters, 0, (value.Length - 1));

            if (!(Char.IsLetter(firstLetter) || firstLetter == '_')) throw new ArgumentException("not an identifier");
            if (anotherLetters.Count(c => !(Char.IsLetterOrDigit(c))) != 0) throw new ArgumentException("not an identifier");

            Value = value;
                
        }
    }
}
